/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ch.easer.zlv.jsf.converter;

import ch.easer.zlv.entity.enums.Waehrung;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

/**
 *
 * @author easy
 */
@FacesConverter(value = "waehrungConverter")
public class WaehrungConverter implements Converter{

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return Waehrung.valueOf(value);
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value == null){
            return "";
        }
        return ((Waehrung)value).name();
    }
    
}
